home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Utilitaires divers / Images / Image 1.37 ƒ / Macros / Image Macros < prev    next >
Encoding:
Text File  |  1990-09-14  |  3.5 KB  |  164 lines  |  [TEXT/MSWD]

  1. {
  2. This file contains contains example macros written in Image's
  3. Pascal-like programming language. These macros will automatically
  4. be loaded when Image is launched as long as this file is in the same folder
  5. as Image, or in the System folder, and it has the name 'Image Macros'.
  6. }
  7.  
  8. macro 'Measure [1]'       begin Measure end;
  9. macro 'Show Results [2]'  begin ShowResults end;
  10. macro 'Reset [3]'         begin ResetCounters end;
  11. macro 'Copy Results [4]'  begin CopyResults end;
  12. macro 'Start Capture [G]' begin StartCapturing end;
  13.  
  14.  
  15. Macro 'Draw Arrow Head [A]'
  16. {Draws an arrow head on the last line drawn with the ruler tool.}
  17. var
  18.   size,angle,dx,dy,pi,theta:real;
  19.   x1,y1,x2,y2,LineWidth,width,height:integer;
  20. begin
  21.   size:=12;  {pixels}
  22.   angle:=20; {degrees}
  23.   pi:=3.14159;
  24.   GetLine(x1,y1,x2,y2,LineWidth);
  25.   if x1<0 then begin
  26.     PutMessage('Use the ruler to draw a line first.');
  27.     exit;
  28.   end;
  29.   GetPicSize(width,height);
  30.   y1:=height-y1;
  31.   y2:=height-y2;
  32.   if LineWidth>1 then size:=size*LineWidth*0.5;
  33.   angle:=(angle/180)*pi;
  34.   dx:=x1-x2;
  35.   dy:=y1-y2;
  36.   if dx=0 then begin
  37.     if dy>=0 then theta:=pi/2 else theta:=3/2*pi
  38.   end else begin
  39.     theta:=arctan(dy/dx);
  40.     if dx<0 then theta:=theta+pi;
  41.   end;
  42.   moveto(x2,height-y2);
  43.   lineto(x2+size*cos(theta+angle),height-(y2+size*sin(theta+angle)));
  44.   moveto(x2,height-y2);
  45.   lineto(x2+size*cos(theta-angle),height-(y2+size*sin(theta-angle)));
  46. end;
  47.  
  48.  
  49. macro 'Print All';
  50. {Use SetOption, which turns off halftoning, for better quality}
  51. {(and faster) printing of binary pictures.}
  52. var
  53.   i:integer;
  54. begin
  55.   for i:=1 to nPics do begin
  56.      SelectPic(i);
  57.      {SetOption;}
  58.      Print;
  59.   end;
  60. end;
  61.  
  62.  
  63. macro 'Clear Outside'
  64.  {Erase region outside current selection to background color.}
  65. begin
  66.   Copy;
  67.   SelectAll;
  68.   Clear;
  69.   RestoreRoi;
  70.   Paste;
  71.   KillRoi;
  72. end;
  73.  
  74.  
  75. macro 'Make Bas-relief'
  76. begin
  77.   SelectAll;
  78.   {SetOption; Smooth;}
  79.   Copy;
  80.   KillRoi;
  81.   Duplicate('Bas-relief');
  82.   SelectAll;
  83.   MoveRoi(-1,-1);  {Try MoveRoi(1,1) for a different effect.}
  84.   Paste;
  85.   Subtract;
  86.   EnhanceContrast;
  87.   ApplyLUT;
  88. end;
  89.  
  90.  
  91. macro '(-' begin end;
  92.  
  93.  
  94. macro 'Make Step Function';
  95. {Generates a grayscale step function within the current selection.}
  96. var
  97.   left,top,width,height,nSteps,StepSize,i,x:integer;
  98.   value:real;
  99. begin
  100.   GetRoi(left,top,Width,Height);
  101.   if width=0 then begin
  102.     PutMessage('This macro requires a rectangular selection.');
  103.     Exit;
  104.   end;
  105.   nSteps:=GetNumber('Number of steps',16);
  106.   value:=255;
  107.   StepSize:=width div nSteps;
  108.   x:=left;
  109.   for i:=1 to nSteps do begin
  110.     MakeRoi(x,top,StepSize,Height);
  111.     SetForeground(round(value));
  112.     fill;
  113.     x:=x+StepSize;
  114.     value:=value-256/nSteps;
  115.   end;
  116.   KillRoi;;
  117. end;
  118.  
  119.  
  120. macro 'Random Ovals';
  121. var
  122.   PicWidth,PicHeight,hloc,vloc,width,height:real;
  123. begin
  124.   SetPalette('Spectrum');
  125.   MakeNewWindow('Random Ovals');
  126.   GetPicSize(PicWidth,PicHeight);
  127.   repeat
  128.     hloc:=width*random;
  129.     vloc:=height*random;
  130.     width:=(PicWidth-hloc)*random;
  131.     height:=(PicHeight-vloc)*random;
  132.     MakeOvalRoi(hloc,vloc,width,height);
  133.     SetForeground(255*random);
  134.     fill;
  135.   until Button;
  136.   KillRoi;
  137. end;
  138.  
  139.  
  140. macro 'Draw Ball';
  141. var
  142.   width,height,n,i,color,diam,nSteps:integer;
  143. begin
  144.   nSteps:=64;
  145.   SetPalette('Spectrum');
  146.   SetBackground(255); {Black}
  147.   MakeNewWindow('Ball');
  148.   GetPicSize(Width,Height);
  149.   if width>height
  150.     then diam:=height
  151.     else diam:=width;
  152.   color:=1;
  153.   MakeOvalRoi((width-diam)/2,(height-diam)/2,diam,diam);
  154.   for i:=1 to nSteps do begin
  155.     InsetRoi(round(diam/(3*nSteps)));
  156.     SetForeground(color);
  157.     fill;
  158.     color:=color+round(256/nSteps);
  159.     if color>254 then color:=254;
  160.   end;
  161.   KillRoi;;
  162. end;
  163.  
  164.